# 函数
# 定义函数 def fn_name ():
# 函数形参、实参
# 实参传递方式，位置实参、默认参数、关键字参数
# 返回值
# 任意参数 *
# 任意关键字参数 **
# 模块

# 导入模块
import pizza

# 给模块指定别名
# import pizza as p

# 导入所有函数
# from pizza import *

# 导入模块中特定函数
from car import make_car

# 给模块中函数指定别名
from car import make_car as gen_car

def greet_user(name: str):
    message = 'Hello, '
    print(message + name.title() + '!')

greet_user('haha')

greet_user('wangwu')

def describe_pet(animal_type: str = 'dog', pet_name: str = 'ha'):
    print('\nI hava a ' + animal_type + '.')
    print('My' + animal_type + "'s name is " + pet_name.title() + '.')


# 参数默认值
describe_pet()

# 位置实参
describe_pet('hamster', 'harry')

# 关键字实参，顺序不影响
describe_pet(pet_name='harry', animal_type='hamster')

# 练习

def make_shirt(size: str, tip: str = 'I love Python'):
    print('this shirt size is ' + size + ',have text:' + tip)

make_shirt('smart', 'python')
make_shirt(tip='java', size='large')


# 返回值 return
def get_formatted_name(first_name: str, last_name: str):
    """返回整洁的姓名"""
    full_name = first_name + ' ' + last_name
    return full_name.title()

musician = get_formatted_name('jimi', 'hendrix')
print(musician)

# 练习

def make_album(singer_name: str, album_name: str, song_num = 0):
    album = {}
    album['singer'] = singer_name
    album['name'] = album_name
    if (song_num > 0):
        album['num'] = song_num
    return album

album_list = []
def print_your_album():
    while True:
        name = input('\nPlease tell me album name:')
        if name == 'q':
            break
        singer = input('\nPlease tell me singer name:')
        if singer == 'q':
            break
        num = input('\nPlease tell me album num:')
        if num == 'q':
            break
        album = make_album(singer, name, int(num))
        album_list.append(album)
        print('album:\n', album_list)

print_your_album()

# 模块
pizza.make_pizza('pepefaj')
pizza.make_pizza('mushrooms', 'grent peppers', 'extra cheese')

make_car('subaru', 'ouotback', color='blue', tow_package=True)
gen_car('subaruss', 'ouotbackss', color='yellow', tow_package=False)